
import com.mysql.jdbc.Connection;
import java.lang.String;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Proveedor1.java
 *
 * Created on 30/01/2012, 07:13:14 PM
 */
/**
 *
 * @author JOSE LUIS
 */
public class Proveedor1 extends javax.swing.JInternalFrame {
   
    String[] prov={"Seleccionar Provincia...","Azuay", "Bolivar", "Cañar", "Carchi","Chimborazo","Cotopaxi","El Oro","Esmeraldas",
    "Galapagos","Guayas","Imbabura","Loja","Los Rios","Manabì","Morona Santiago","Napo","Orellana","Pastaza","Pichincha","Santa Elena","Santo Domingo de los Sàchilas","Sucumbios",
    "Tunguahua","Zamora Chinchipe"};
    String[] Guayas ={"Balao","Balzar","Colimes","Daule","Duran","El Empalme","El Triunfo","Guayaquil","Isidro Ayora","Jujan",
        "Lomas de Sargentillo","Marcelino Maridueña","Milagro","Naranjal","Naranjito","Nobol","Palestina","Pedro Carbo",
        "Playas","San Borondon","Santa Lucia","Simón Bolívar","Salitre","Yaguachi"};
    String[] Azuay ={"Camilo Ponce Enriquez","Chordeleg","Cuenca","El Pan","Giron","Guachapala","Gualaceo","Molleturo","Nabon","Paute","Pucará","San Felipe de Oña","San Fernando","Santa Isabel","Sevilla del Oro","Sigsig"};
    String[] Canar = {"Azoguez","Biblián","Cañar","Déleg","El Tambo","La Troncal","Suscal"};
    String[] Bolivar = {"Caluma","Chillanes","Chimbo","Déleg","Echendia","Guaranda","Las Naves","San Miguel"};
    String[] Carchi = {"Bolivar","Espejo","Mira","San Pedro de Huaca","Tulcan"};
    String[] Chimborazo = {"Alausí","Chambo","Chunchi","Colta","Cumandá","Guamote","Guano","Pallatanga","Penipe","Riobamba"};
    String[] Cotopaxi = {"La Maná","Latacunga","Pangua","Pujilí","Sigchos","Salcedo","Saquisilí"};
    String[] Oro = {"Arenillas","Atahualpa","Balsa","Chilla","El Guabo","Huaquillas","Macarbelí","Machala","Pasaje","Piñas","Portovelo","Santa Rosa","Zaruma"};
    Conexion con = new Conexion();
    Connection conect = null;
     ResultSet rs;
     java.sql.Statement st=null;
     
  //como es que lo hisiste?   Con afreglos la varoables de provincias luego
 int cop=0,rep=0;
    /** Creates new form Proveedor1 */
    public Proveedor1() {
        initComponents();
        //
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        codigo = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        Nombre = new javax.swing.JTextField();
        Fax = new javax.swing.JFormattedTextField();
        Tel = new javax.swing.JFormattedTextField();
        Direccion = new javax.swing.JTextField();
        Mail = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        String gui,me;
        Calendar c1 = Calendar.getInstance();
        String dia = Integer.toString(c1.get(Calendar.DATE));
        String mes = Integer.toString(c1.get(Calendar.MONTH) + 1);
        String ano = Integer.toString(c1.get(Calendar.YEAR));
        if(c1.get(Calendar.MONTH) + 1 == 1) {mes="Enero";}
        if(c1.get(Calendar.MONTH) + 1 == 2) {mes="Febrero";}
        if(c1.get(Calendar.MONTH) + 1 == 3) {mes="Marzo";}
        if(c1.get(Calendar.MONTH) + 1 == 4) {mes="Abril";}
        if(c1.get(Calendar.MONTH) + 1 == 5) {mes="Mayo";}
        if(c1.get(Calendar.MONTH) + 1 ==6) {mes="Junio";}
        if(c1.get(Calendar.MONTH) + 1 == 7) {mes="Julio";}
        if(c1.get(Calendar.MONTH) + 1 == 8) {mes="Agosto";}
        if(c1.get(Calendar.MONTH) + 1 == 9) {mes="Septiembre";}
        if(c1.get(Calendar.MONTH) + 1 == 10) {mes="Octubre";}
        if(c1.get(Calendar.MONTH) + 1 == 11) {mes="Noviembre";}
        if(c1.get(Calendar.MONTH) + 1 == 12) {mes="Diciembre";}

        gui = (dia + "/" + mes+ "/" + ano);
        Fecha = new javax.swing.JLabel();
        Codigo = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        Apellido = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        Provincia = new javax.swing.JComboBox();
        Ciudad = new javax.swing.JComboBox();

        setClosable(true);
        setTitle("Proveedor - Ingreso");

        codigo.setFont(new java.awt.Font("Tahoma", 0, 18));
        codigo.setText("Codigo");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel2.setText("Nombre");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel3.setText("Telefono");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel4.setText("Fax");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel5.setText("Dirección");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel6.setText("Provincia");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel8.setText("Mail");

        Nombre.setFont(new java.awt.Font("Tahoma", 0, 18));
        Nombre.setText("");

        try {
            Fax.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##-#######")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        Fax.setFont(new java.awt.Font("Tahoma", 0, 18));
        Fax.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FaxActionPerformed(evt);
            }
        });

        try {
            Tel.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##-#######")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        Tel.setFont(new java.awt.Font("Tahoma", 0, 18));

        Direccion.setFont(new java.awt.Font("Tahoma", 0, 18));
        Direccion.setText(" ");
        Direccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DireccionActionPerformed(evt);
            }
        });

        Mail.setFont(new java.awt.Font("Tahoma", 0, 18));

        jButton1.setFont(new java.awt.Font("Tahoma", 0, 14));
        jButton1.setText("Guardar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setFont(new java.awt.Font("Tahoma", 0, 14));
        jButton2.setText("Cancelar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel9.setText("Fecha");

        Fecha.setBackground(new java.awt.Color(0, 51, 153));
        Fecha.setFont(new java.awt.Font("Tahoma", 0, 18));
        Fecha.setForeground(new java.awt.Color(0, 51, 204));
        Fecha.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Fecha.setText(gui);

        Codigo.setBackground(new java.awt.Color(51, 51, 255));
        Codigo.setFont(new java.awt.Font("Tahoma", 0, 24));
        Codigo.setForeground(new java.awt.Color(0, 0, 255));
        Codigo.setText("");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel10.setText("Apellidos");

        Apellido.setFont(new java.awt.Font("Tahoma", 0, 18));
        Apellido.setText("");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel7.setText("Ciudad");

        Provincia.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        Provincia.setModel(new javax.swing.DefaultComboBoxModel(prov));
        Provincia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                ProvinciaItemStateChanged(evt);
            }
        });
        Provincia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ProvinciaActionPerformed(evt);
            }
        });

        Ciudad.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(18, 18, 18)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(48, 48, 48)
                                            .addComponent(Codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(Ciudad, javax.swing.GroupLayout.Alignment.TRAILING, 0, 270, Short.MAX_VALUE)
                                        .addComponent(Mail, javax.swing.GroupLayout.Alignment.TRAILING)))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(18, 18, 18)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(Apellido, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                                        .addComponent(Nombre, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                                        .addComponent(Tel, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                                        .addComponent(Fax, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                                        .addComponent(Provincia, 0, 270, Short.MAX_VALUE)
                                        .addComponent(Direccion, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(53, 53, 53)
                                .addComponent(Fecha))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(65, 65, 65)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(63, 63, 63)))
                .addGap(65, 65, 65))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Codigo)
                    .addComponent(codigo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Apellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Tel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Fax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Provincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Ciudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Mail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Fecha, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(35, 35, 35)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(46, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(276, 276, 276)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
   
 //   int en = Integer.parseInt(codi);
    
    if (rep==0)
    {
         codigo();
     String codi,nomi,ape,corr,tel,fax,dir,ciu,pro ; 
    codi = Codigo.getText();nomi = Nombre.getText();ape = Apellido.getText();corr = Mail.getText();
     tel = Fax.getText();fax = Tel.getText();dir = Direccion.getText();ciu = (String) Ciudad.getSelectedItem();
     pro = (String) Provincia.getSelectedItem();
     Conexion u = new Conexion();
     
     u.insert("proveedores","id,nombre,apellidos,correo,telefono,NumerodeFax,Dierccion,Ciudad,Provincia,registro"," '"+codi+"','"+nomi+"', '"+ape+"' , '"+corr+"', '"+tel+"', '"+fax+"', '"+dir+"','"+ciu+"','"+pro+"','"+cop+"'");//Persona id=new Persona();        
      
     rep ++;
    //boolean cod = bCodigo(Codigo.getText());
    }else{
       JOptionPane.showMessageDialog(rootPane,"No se puede grabar con codigo Repetido"); 
              
    }
        
             
     
        
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
    setVisible(false);
    
    
    System.out.println("u");
}//GEN-LAST:event_jButton2ActionPerformed

private void DireccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DireccionActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_DireccionActionPerformed

private void ProvinciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ProvinciaActionPerformed
        // TODO add your handling code here:
    
    int pos=0;int x;  // POs es la Pocision del arreglo 
    pos = Provincia.getSelectedIndex();  // Captura las posiciones de Objeto Item
    switch(pos){
        case 0:
            Ciudad.removeAllItems();
            break;
        case 1 :                                 //Posicion 0 es azuay  
             Ciudad.removeAllItems(); 
            x=0;                   
            do{      
            Ciudad.addItem(Azuay[x]);
            x++;
            }while(x<16);        // controla u bucle de 16 porque tiene 16 provincias(tamaño del arreglo) una pregunta mas bien dicho ya esta guardando? todavia n
            break;
            
      case 2 :                                 //Posicion 0 es azuay  
             Ciudad.removeAllItems(); 
            x=0;                   
            do{      
            Ciudad.addItem(Bolivar[x]);
            x++;
            }while(x<8);        // controla u bucle de 16 porque tiene 16 provincias(tamaño del arreglo) una pregunta mas bien dicho ya esta guardando? todavia n
            break;
     case 3:
            Ciudad.removeAllItems(); 
             x=0;
            do{
            Ciudad.addItem(Canar[x]);    
            x++;
            }while(x<7);
            break;     
     case 4 :                                 //Posicion 0 es azuay  
             Ciudad.removeAllItems(); 
            x=0;                   
            do{      
            Ciudad.addItem(Carchi[x]);
            x++;
            }while(x<5);        // controla u bucle de 16 porque tiene 16 provincias(tamaño del arreglo) una pregunta mas bien dicho ya esta guardando? todavia n
            break; 
       case 5 :                                 //Posicion 0 es azuay  
             Ciudad.removeAllItems(); 
            x=0;                   
            do{      
            Ciudad.addItem(Chimborazo[x]);
            x++;
            }while(x<10);        // controla u bucle de 16 porque tiene 16 provincias(tamaño del arreglo) una pregunta mas bien dicho ya esta guardando? todavia n
            break; 
      case 6 :                                 //Posicion 0 es azuay  
             Ciudad.removeAllItems(); 
            x=0;                   
            do{      
            Ciudad.addItem(Cotopaxi[x]);
            x++;
            }while(x<7);        // controla u bucle de 16 porque tiene 16 provincias(tamaño del arreglo) una pregunta mas bien dicho ya esta guardando? todavia n
            break; 
     case 7 :                                 //Posicion 0 es azuay  
             Ciudad.removeAllItems(); 
            x=0;                   
            do{      
            Ciudad.addItem(Oro[x]);
            x++;
            }while(x<13);        // controla u bucle de 16 porque tiene 16 provincias(tamaño del arreglo) una pregunta mas bien dicho ya esta guardando? todavia n
            break;      
        case 10:         
            Ciudad.removeAllItems(); 
             x=0;
            do{
            Ciudad.addItem(Guayas[x]);    
            x++;
            }while(x<24);
            break;
        
        default :
             JOptionPane.showMessageDialog(null,"Error -- ");
             Ciudad.removeAllItems();  
    }
      
       
         
       
  
           
           
    
}//GEN-LAST:event_ProvinciaActionPerformed

private void ProvinciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_ProvinciaItemStateChanged
// TODO add your handling code here:
    
   
}//GEN-LAST:event_ProvinciaItemStateChanged

private void FaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FaxActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_FaxActionPerformed
public String VerificarRe(){
  //   Connection conect = null;
    String nomi=null;
     int s=0;
        String query = "SELECT * FROM proveedores WHERE id= (SELECT MAX(id) FROM proveedores)";
     // JOptionPane.showMessageDialog(null,query);
        try {
            conect = (Connection) con.getConnection();
  
             st=  conect.createStatement();           
             rs = st.executeQuery(query);
             
             while (rs.next()){
                 nomi=rs.getString("registro");
                // System.out.println();
             if (rs.getString(1)==null){
                 
                     s=0;
                 }else{
                     s=1;
                 }    
             }
        } catch (SQLException ex) {
          
          //  Logger.getLogger(Consultas.class.getName()).log(Level.SEVERE, null, ex);
              JOptionPane.showMessageDialog(null,"Error -- " +ex);
        }
   if (s==1)
        return nomi;
     else 
        return nomi; 
   
     
 }
 public boolean bCodigo(String Cod){     // Cedula
     
 
     int s=0;
   String  query = "SELECT * FROM Paciente WHERE Cedula='"+Cod+"'";
     
        try {
            conect = (Connection) con;
  
             st=  conect.createStatement();           
             rs = st.executeQuery(query);
             while (rs.next()){
             if (rs.getString(1)==null){
                     s=0;
                 }else{
                     s=1;
                 }    
             }
        } catch (SQLException ex) {
          
          //  Logger.getLogger(Consultas.class.getName()).log(Level.SEVERE, null, ex);
              JOptionPane.showMessageDialog(null,"Error -- " +ex);
        }
    if (s==1)
        return true;
     else 
        return false;
    
     
 }
public void codigo(){
    String u = VerificarRe();       
int ce = Integer.parseInt(u);
ce++;

 cop =ce;
String g= Integer.toString(ce);
Codigo.setText(g);
}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField Apellido;
    private javax.swing.JComboBox Ciudad;
    private javax.swing.JLabel Codigo;
    private javax.swing.JTextField Direccion;
    private javax.swing.JFormattedTextField Fax;
    private javax.swing.JLabel Fecha;
    private javax.swing.JTextField Mail;
    private javax.swing.JTextField Nombre;
    private javax.swing.JComboBox Provincia;
    private javax.swing.JFormattedTextField Tel;
    private javax.swing.JLabel codigo;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
